﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace _18.Application类 {
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application {
        private void Application_SessionEnding(object sender, SessionEndingCancelEventArgs e) {
            //在windows会话结束时触发，比如当前windows用户注销
        }

        private void Application_Activated(object sender, EventArgs e) {
            //切换到当前windows应用时触发
        }

        private void Application_Exit(object sender, ExitEventArgs e) {
            //窗口关闭时触发
        }

        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) {
            //应用程序任意位置发生未处理异常时触发
        }

        protected override void OnSessionEnding(SessionEndingCancelEventArgs e) {
            //.netcore没办法拦截，怪；framework还没试
            //base.OnSessionEnding(e);
            //e.Cancel = true;
            //MessageBox.Show("无法注销或关闭系统");
        }

        private void Application_Startup(object sender, StartupEventArgs e) {
            MainWindow win = new MainWindow();
            Window1 win1 = new Window1();
            if(e.Args.Length == 0) { return; }
            string file = e.Args[0];
            if (File.Exists(file)) {
                //win.LoadFile(file);
            }
            win.Show();
            win1.Show();
        }

        private List<Document> documents = new List<Document>();

        public List<Document> Documents { 
            get { return documents; }
            set { documents = value; }
        }
    }
}
